package ar.com.fiuba.ElectronicCircuitAnalyst.application.api;

import ar.com.fiuba.ElectronicCircuitAnalyst.application.api.dto.CircuitDto;
import ar.com.fiuba.ElectronicCircuitAnalyst.domain.exceptions.AlreadyExistingCircuitElementException;
import ar.com.fiuba.ElectronicCircuitAnalyst.domain.exceptions.CircuitElementNotFoundException;
import ar.com.fiuba.ElectronicCircuitAnalyst.domain.exceptions.InvalidCircuitElementException;

/**
 * Interface for a service that provides operations over circuits. It works
 * basically as a CRUD for circuits.
 * 
 */
public interface CircuitService {

	/**
	 * Method to make a circuit with the specifications given.
	 * 
	 * @param data
	 *            the DTO holding the information to create the Circuit. The
	 *            name of the circuit to be modified is taken from the DTO too.
	 * @throws InvalidCircuitElementException
	 *             if there's any inconsistency in the parameters.
	 * @throws AlreadyExistingCircuitElementException
	 *             if there's circuit with the same name exists.
	 */
	public void makeCircuit(CircuitDto data) throws InvalidCircuitElementException,
			AlreadyExistingCircuitElementException;

	/**
	 * Method to modify a circuit.
	 * 
	 * @param data
	 *            the DTO holding the information to modify the Circuit.
	 * @throws InvalidCircuitElementException
	 *             if there's any inconsistency in the parameters.
	 * @throws CircuitElementNotFoundException
	 *             if there's no such circuit with the provided name.
	 */
	public void modifyCircuit(CircuitDto data) throws InvalidCircuitElementException, CircuitElementNotFoundException;

	/**
	 * Method to remove a circuit.
	 * 
	 * @param name
	 *            name of the undesired circuit.
	 * @throws CircuitElementNotFoundException
	 *             if there's no such circuit with the name.
	 * @throws InvalidCircuitElementException
	 *             if there's an error reaching the circuit.
	 */
	public void removeCircuit(String name) throws CircuitElementNotFoundException, InvalidCircuitElementException;

	/**
	 * Method to remove any circuit related directly or indirectly to the
	 * circuit element with the given name. For example, if circuit A uses
	 * circuit B and circuit B uses component C, when calling the method with C
	 * this should return both A and B.
	 * 
	 * @param name
	 *            the name of the circuit element thi circuits would be related
	 *            to.
	 * @throws InvalidCircuitElementException
	 *             if there's an error reaching any circuit.
	 */
	public void removeRelatedCircuits(String name) throws InvalidCircuitElementException;

}
